$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    console.log('detail Ready');
    var mstform = $NG.getCmpApi('p_form_http_m');

    useValuesChange(({ args }) => {
        let user_bdmc = mstform.getItem('u_bdmc').getValue();
        console.log("当前BDMC值:", user_bdmc);
        if (mstform.getItem('u_ywlb').getValue() == 6870000000000112) {
            $NG.updateUI((updater) => {
                const fields = ["u_hylb", 'u_ejhylb', 'u_scfw'];
                fields.forEach((field) => {
                    updater.fieldSetForm.p_form_http_m[field].setProps({
                        hidden: true, //隐藏
                        required: false, //必输
                        // disabled: true, //只读
                    });
                });
            });
        }
        if (mstform.getItem('u_sccyllb').getValue() == 6870000000000085) {
            $NG.updateUI((updater) => {
                const fields = ["u_hylb", 'u_ejhylb', 'u_scfw'];
                fields.forEach((field) => {
                    updater.fieldSetForm.p_form_http_m[field].setProps({
                        hidden: true, //隐藏
                        required: false, //必输
                        // %disabled: true, //只读
                    });
                });
            });
        }
        $NG.execServer("searchHttp", { user_bdmc: user_bdmc }, (res) => {
            if (res.count === 0) return;
            const bdmcData = JSON.parse(res.data)[0].extendObjects;
            console.log("searchHttp返回:", bdmcData);
            if (bdmcData.user_ywlb == 6870000000000112) {
                $NG.updateUI((updater) => {
                    const fields = ["u_hylb", 'u_ejhylb', 'u_scfw'];
                    fields.forEach((field) => {
                        updater.fieldSetForm.p_form_http_m[field].setProps({
                            hidden: true, //隐藏
                            required: false, //必输
                            // disabled: true, //只读
                        });
                    });
                });
            }
            if (bdmcData.user_sccyllb == 6870000000000085) {
                $NG.updateUI((updater) => {
                    const fields = ["u_hylb", 'u_ejhylb', 'u_scfw'];
                    fields.forEach((field) => {
                        updater.fieldSetForm.p_form_http_m[field].setProps({
                            hidden: true, //隐藏
                            required: false, //必输
                            // disabled: true, //只读
                        });
                    });
                });
            }
            $NG.execServer("searchXmms", { phid: bdmcData.user_xmms }, (res2) => {
                if (res2.count === 0) return;
                const xmmsData = JSON.parse(res2.data)[0].extendObjects;
                console.log(xmmsData);

                const user_xmms_EXName = xmmsData.c_name;
                $NG.updateState((updater) => {
                    updater.data.p_form_http_m.setProps({
                        u_Xmbh: bdmcData.bill_no,
                        u_yzdw: bdmcData.user_yzdw,
                        // bill_name: bdmcData.project_name,
                        // bill_name: {
                        //     value: bdmcData.user_xmms,
                        //     label: user_xmms_EXName,
                        // },
                        // u_tbsj: bdmcData.project_name,
                        u_scfw: bdmcData.user_scfw,
                        u_xmms: {
                            value: bdmcData.user_xmms,
                            label: user_xmms_EXName,
                        }
                    });
                });
            });
            $NG.execServer("searchYwlb", { phid: bdmcData.user_ywlb }, (res2) => {
                if (res2.count === 0) return;
                const xmmsData = JSON.parse(res2.data)[0].extendObjects;
                const user_xmms_EXName = xmmsData.c_name;
                $NG.updateState((updater) => {
                    updater.data.p_form_http_m.setProps({
                        u_ywlb: {
                            value: bdmcData.user_ywlb,
                            label: user_xmms_EXName,
                        }
                    });
                });
            });
            $NG.execServer("searchSccyllb", { phid: bdmcData.user_sccyllb }, (res2) => {
                if (res2.count === 0) return;
                const xmmsData = JSON.parse(res2.data)[0].extendObjects;
                const user_xmms_EXName = xmmsData.c_name;
                $NG.updateState((updater) => {
                    updater.data.p_form_http_m.setProps({
                        u_sccyllb: {
                            value: bdmcData.user_sccyllb,
                            label: user_xmms_EXName,
                        }
                    });
                });
            });
            $NG.execServer("searchYjhylb", { phid: bdmcData.user_hylb }, (res2) => {
                if (res2.count === 0) return;
                const xmmsData = JSON.parse(res2.data)[0].extendObjects;
                const user_xmms_EXName = xmmsData.c_name;
                $NG.updateState((updater) => {
                    updater.data.p_form_http_m.setProps({
                        u_hylb: {
                            value: bdmcData.user_sccyllb,
                            label: user_xmms_EXName,
                        }
                    });
                });
            });
            $NG.execServer("searchYwlb", { phid: bdmcData.user_ejhylb }, (res2) => {
                if (res2.count === 0) return;
                const xmmsData = JSON.parse(res2.data)[0].extendObjects;
                const user_xmms_EXName = xmmsData.c_name;
                $NG.updateState((updater) => {
                    updater.data.p_form_http_m.setProps({
                        u_ejhylb: {
                            value: bdmcData.user_ejhylb,
                            label: user_xmms_EXName,
                        }
                    });
                });
            });
            // $NG.execServer("serachTbdw", { phid: bdmcData.user_tbdw }, (res2) => {
            //     if (res2.count === 0) return;
            //     const xmmsData = JSON.parse(res2.data)[0].extendObjects;
            //     const user_xmms_EXName = xmmsData.oname;
            //     $NG.updateState((updater) => {
            //         updater.data.p_form_http_m.setProps({
            //             u_tbdw: {
            //                 value: bdmcData.user_tbdw,
            //                 label: user_xmms_EXName,
            //             }
            //         });
            //     });
            // });
        });
    }, "p_form_http_m.u_bdmc");
    $NG.updateState((updater) => {
        updater.data.p_form_http_m.setProps({
            u_tpcs: $NG.getCmpApi('p_form_http_d2').getRows().length,
        });
    });
    useUpdateRows(({ args, table }) => {
        console.log($NG.getCmpApi('p_form_http_d2').getRows());
        $NG.updateState((updater) => {
            updater.data.p_form_http_m.setProps({
                u_tpcs: $NG.getCmpApi('p_form_http_d2').getRows().length,
            });
        });

    }, 'p_form_http_d2');
}, function () {
    console.log('list Ready');
});